/*
 * @(#)HapiHttpClientITCase.java
 * Date 2013-03-26
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.hapiclient;

import java.net.URL;

import ca.uhn.hl7v2.model.Message;
import ca.uhn.hl7v2.parser.PipeParser;

import java.io.InputStream;
import org.apache.commons.io.IOUtils;

import org.junit.Test;
import static org.junit.Assert.assertNotNull;


/**
 * Class description
 *
 *
 * @version        v1.0, 2013-03-26
 * @author         Jim Horner
 */
public class HapiHttpClientITCase {

    /**
     * Method description
     *
     *
     * @throws Exception
     */
    @Test
    public void sendMessageTest() throws Exception {

        URL url = new URL("http://localhost:36880/schedule/");
        HapiClientConfig config = new HapiClientConfig(url);
        HapiHttpClient client = new HapiHttpClient(config);

        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        InputStream ios = cl.getResourceAsStream("test-message.txt");

        assertNotNull(ios);
        
        String msg = IOUtils.toString(ios, "UTF-8");
        PipeParser parser = new PipeParser();
        Message response = client.sendMessage(parser.parse(msg));
    }
}
